package cn.cht.mvcframework.demo.controller;

import cn.cht.mvcframework.annotations.MyAutowired;
import cn.cht.mvcframework.annotations.MyController;
import cn.cht.mvcframework.annotations.MyRequestMapping;
import cn.cht.mvcframework.annotations.MySecurity;
import cn.cht.mvcframework.demo.service.DemoService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@MyController
@MyRequestMapping("/demo")
@MySecurity({"cht"})
public class DemoController {

    @MyAutowired
    private DemoService demoService;

    /**
     * /demo/query
     * @param request
     * @param response
     * @param name
     * @return
     */
    @MyRequestMapping("/query1")
    public String getName1(HttpServletRequest request, HttpServletResponse response,String name){
        System.out.println("DemoController的方法getName参数:"+name);
        return  demoService.get(name);
    }


    @MySecurity({"xiaobai"})
    @MyRequestMapping("/query2")
    public String getName2(HttpServletRequest request, HttpServletResponse response,String name){
        System.out.println("DemoController的方法getName参数:"+name);
        String s = demoService.get(name);
        return s;
    }


    @MySecurity({"xiaobai","xiaohei"})
    @MyRequestMapping("/query3")
    public String getName3(HttpServletRequest request, HttpServletResponse response,String name){
        System.out.println("DemoController的方法getName参数:"+name);
        return  demoService.get(name);
    }
}
